Given that $$(x+y+z)(xy+xz+yz)=18$$and that $$x^2(y+z)+y^2(x+z)+z^2(x+y)=6$$for real numbers $x$, $y$, and $z$, what is the value of $xyz$?
Solution: Expanding the first given equation using the distributive property, we have \begin{align*}
&18=(x+y+z)(xy+xz+yz)\\
&=x\cdot(xy+xz+yz)+y\cdot(xy+xz+yz)+z\cdot(xy+xz+yz)\\
&=x^2y+x^2z+xyz+xy^2+xyz+y^2z+xyz+xz^2+yz^2\\
&=3xyz+x^2y+x^2z+xy^2+y^2z+xz^2+yz^2
\end{align*}Expanding the second given equation using the distributive property, we have \begin{align*}
6&=x^2(y+z)+y^2(x+z)+z^2(x+y)\\
&=x^2y+x^2z+xy^2+y^2z+xz^2+yz^2.\end{align*}We substitute the equation $$6=x^2y+x^2z+xy^2+y^2z+xz^2+yz^2$$into the expanded form of the first given equation to get \[18=3xyz+6\]or $xyz=\boxed{4}$.